<%--
   processTrace
   Copyright (c) 2013 ISPERP
   Version : 1.0.0
 --%>
<%@ tag language="java" pageEncoding="UTF-8"
	trimDirectiveWhitespaces="true"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>

<%@ attribute name="processId" required="true" rtexprvalue="true"
	type="java.lang.String" description="任务Id(processId)"%>

<div class="comments">
	<ul id="ul${processId }">
	</ul>
</div>
<script type="text/javascript">
	$.get("api/workflow/processRun/trace?processId=${processId}", function(data) {

		var $node = $("#ul${processId }");
		$(data.historys).each(function(index, item) {
			$node.append(generalProcessTrac(index, item));
		});

		if (data.areRunning == "1") {
			var html = generalProcessTracRunning(data.currentTaskName, data.currentTaskCreateTime, data.currentUsers);
			$node.append(html);
		}

	});

	function generalProcessTrac(index, item) {
		var html = '<li class="row_' + index % 2 + '">';
		html += '<table><tr><td class="body">';

		html += '<div class="r_title" id="t_'+item.TASK_DEF_KEY_+'">';

		html += '<b>' + (item.fullname || "") + '</b>';
		html += '&nbsp;&nbsp;<label>' + item.action_time + '</label>';
		html += '&nbsp;在“' + (item.NAME_|| "开始") + '”执行“' + (item.action_name || "") + '”';
		html += '<div class="r_content TextContent">';
		html += '	处理意见：' + (item.comment || "") + ' <br>';
		html += '</div>';
		html += '</div>';

		return html;

	}

	function generalProcessTracRunning(currentTaskName, currentTaskCreateTime, currentUsers) {
		var html = '<li class="row_">';
		html += '<table><tr><td class="body">';

		html += '<div id="t_running" class="r_title" style="color:red">';
		html += '&nbsp;进行中任务:“' + currentTaskName + '”(到达时间：';
		html += '<label>"' + currentTaskCreateTime + '" )';
		html += '<div class="">';
		html += '	&nbsp;候选人:<b>' + currentUsers + '</b>';

		html += '</div>';
		html += '</div>';
		return html;
	}
</script>